package com.baibang.baibang815.controller;


import com.baibang.baibang815.domain.Address;
import com.baibang.baibang815.service.AddressService;
import com.baibang.baibang815.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/address")
@Api(tags = "地址管理")
public class AddressController {

    @Autowired
    private AddressService addressService;

    @GetMapping("/getAddressById")
    @ApiOperation(value = "根据ID查询地址信息")
    public AjaxResult getAddressById(@RequestParam int id) {
        // 白帮 0815
        return AjaxResult.success(addressService.selectById(id));
    }

    @PostMapping("/addAddress")
    @ApiOperation(value = "新增地址")
    public AjaxResult addAddress(@RequestBody Address address) {
        // 白帮 0815
        return AjaxResult.success(addressService.saveAddress(address));
    }

    @PostMapping("/deleteAddress")
    @ApiOperation(value = "删除地址")
    public AjaxResult deleteAddress(@RequestParam int id) {
        // 白帮 0815
        return AjaxResult.success(addressService.deleteAddress(id));
    }
}